import { BaseResultType } from '#/request'
import useDealResult from '@/hooks/dealResult'
import uniRequest from '@/request'

const { dealResult, checkResult } = useDealResult()

export const getUserInfo = async (param: any): Promise<BaseResultType<any> | null> => {
  const [result, err] = await uniRequest.post('11111111', param)
  return Promise.resolve(dealResult(err, result))
}

export const getDeviceInfo = async (deviceId: string): Promise<BaseResultType<any> | null> => {
  const [result, err] = await uniRequest.get('/pb/api/getDeviceInfo?deviceId=' + deviceId)
  return Promise.resolve(dealResult(err, result))
}

export const updateVersion = async (deviceId: string,version:string): Promise<BaseResultType<any> | null> => {
  const [result, err] = await uniRequest.get(`/pb/api/updateVersion?deviceId=${deviceId}&version=${version}`)
  return Promise.resolve(dealResult(err, result))
}


export const orderPbEnd = async (deviceId: string, phon: string, pwd: string, status: string): Promise<BaseResultType<any> | null> => {
  const [result, err] = await uniRequest.get(`/pb/api/orderPbEnd?deviceId=${deviceId}&phon=${phon}&pwd=${pwd}&status=${status}`)
  return Promise.resolve(dealResult(err, result))
}
export const ordergetUserStoragePbEnd = async (deviceId: string, phon: string, pwd: string): Promise<BaseResultType<any> | null> => {
  const [result, err] = await uniRequest.get(`/pb/api/getUserStorage?deviceId=${deviceId}&phon=${phon}&pwd=${pwd}`)
  return Promise.resolve(dealResult(err, result))
}




export const getDeviceList = async (): Promise<BaseResultType<any> | null> => {
  const [result, err] = await uniRequest.get('/pb/api/getDeviceList')
  return Promise.resolve(dealResult(err, result))
}
export const getDeviceInfoToDc = async (deviceId:string): Promise<BaseResultType<any> | null> => {
  const [result, err] = await uniRequest.get('/pb/api/getDeviceInfoToDc?deviceId='+deviceId)
  return Promise.resolve(dealResult(err, result))
}




export const getVersion = async (): Promise<BaseResultType<any> | null> => {
  const [result, err] = await uniRequest.get('/pb/api/getDeviceList')
  return Promise.resolve(dealResult(err, result))
}